float2 iResolution; 
float4 iMouse;

float4x4 modelMatrix;
float4x4 modelViewMatrix;
float4x4 projectionMatrix;
float4x4 viewMatrix;
float3x3 normalMatrix;
float3 cameraPosition;

float sdSphere(float2 p, float r) {
  return length(p) - r;
}

float sdBox( float3 p, float3 b )
{
  float3 q = abs(p) - b;
  return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
}

struct Attributes {
  float4 positionOS : POSITION;
};

struct Varyings {
  float4 positionCS : SV_POSITION;
};

float4 gamma(float4 col) {
  return pow(col, 1 / 2.22);
}

float4 frag(float4 i : SV_POSITION) : SV_TARGET 
{
  // uv 
  float2 p = float2(i.x / iResolution.x, i.y / iResolution.y);
  float4 col = 1.0;
  float2 uv = p;
  uv.x *= (iResolution.x / iResolution.y);
  float2 offset = float2(0.5, 0.5);
  // col = float4(sdSphere(uv - offset, 0.3).xxx, 1.0);
  col = float4(i.xyz, 1.0);
  // col = float4(sdBox(uv - offset, float3(0.3, 0.45, 0.1)).xxx, 1.0);

  col = gamma(col);
  return col;
}